// pages/order/tabDetails/index.js
import Common from '../../../utils/common.js'
let http = new Common()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    showIndex: '',
    orderNum: ''
  },
  //导航
  maps: function () {
    let latitude = parseFloat(wx.getStorageSync('latitude'))
    let longitude = parseFloat(wx.getStorageSync('longitude'))
    let that = this
    wx.openLocation({
      longitude: latitude,
      latitude: longitude,
      address: that.data.info.address,
      success(res) {
        console.log(res)
      },
      fail(res) {
        console.log(res)
      },
    })
  },
  phone: function () {
    let phone = this.data.info.tel
    wx.makePhoneCall({
      phoneNumber: phone
    })
  },     
  OK: function () {
    http.goUrl({
      method: 'switchTab',
      url: '../tabs/index'
    })
  },
  returnIndex: function () {
    wx.switchTab({
      url: '../../index/homePage/index'
    })
  },
  getData: function () {
    let that = this
    let data = {
      orderNo: this.data.orderNum,
      viptel: this.data.tel
    }
    http.http({
      url: 'mp2/store/payafter',
      data: data,
      success(res) {
        that.setData({
          info: res.data.data.info
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
    let tel = wx.getStorageSync('tel')
    this.setData({
      tel: tel
    })
    this.setData({
      showIndex: options.id || '1',
      orderNum: options.orderNum || 'B5bd054bb2370210'
    })
    this.getData()

    console.log(options)
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})